# 信息条
import pygame
import pygame.font
import random
from datetime import datetime

class InfoBar:
    pygame.font.init

    def __init__(self, screen, msg, x=0, y =0):
        
        self.screen = screen
        self.msg = str(msg)
        self.screen_rect = self.screen.get_rect()
        self.text_color = (30, 30, 30)
        self.font = pygame.font.SysFont(None, 40)
        self.x = x
        self.y = y
        self.time = datetime.now()

        self.prep_msg()
        
        print(self.msg, x, y)
    
    def prep_msg(self):
        self.msg_img = self.font.render(self.msg, True, self.text_color)
        self.msg_rect = self.msg_img.get_rect()
        self.msg_rect.centerx = self.x
        self.msg_rect.centery = self.y


    def blitme(self):
        self.screen.blit(self.msg_img, self.msg_rect)
    
    def updateMeg(self, msg):
        self.msg = str(msg)
        self.prep_msg()

